XX     = arm-linux-androideabi-g++
CC     = arm-linux-androideabi-gcc
#XX     = g++
#CC     = gcc
CFLAGS = -O -g


SRC_PATH = /home/incast
NGINX_PATH = /usr/local/nginx/html


INC    = -I$(SRC_PATH)/cloud/jni/vpu/include -I$(SRC_PATH)/cloud/jni/swscale/include -I$(SRC_PATH)/mp4v2-2.0.0/install/include -I$(SRC_PATH)/terminal/include
LIB    = $(SRC_PATH)/out/lib/libfaac.a $(SRC_PATH)/mp4v2-2.0.0/install/lib/libmp4v2.a -L$(SRC_PATH)/cloud/jni/vpu/lib -L$(SRC_PATH)/terminal/lib \
				 -lrk_on2 -lrk_audio -lrk_demux -lstagefright -lvpu -lrkswscale -lz


##INC    = -I/home/incast/cloud/jni/vpu/include -I/home/incast/cloud/jni/swscale/include -I/home/incast/mp4v2-2.0.0/install/include -I/home/incast/terminal/include
##LIB    = /home/incast/out/lib/libfaac.a /home/incast/mp4v2-2.0.0/install/lib/libmp4v2.a -L/home/incast/cloud/jni/vpu/lib -L/home/incast/terminal/lib \
##				 -lrk_on2 -lrk_aincasto -lrk_demux -lstagefright -lvpu -lrkswscale -lz

##INC    = -I/home/incast/cloud/jni/vpu/include -I/home/incast/cloud/jni/swscale/include -I/home/incast/mp4v2-2.0.0/install/include -I/home/incast/terminal/include \
##				 -I/home/incast/external_terminal/iconv/include
##LIB    = /home/incast/out/lib/libfaac.a /home/incast/mp4v2-2.0.0/install/lib/libmp4v2.a -L/home/incast/cloud/jni/vpu/lib -L/home/incast/terminal/lib \
##				 -L/home/incast/external_terminal/iconv/lib \
##				 -lrk_on2 -lrk_aincasto -lrk_demux -lstagefright -lvpu -lrkswscale -lz \
##				 -liconv

TARGET = ./Terminal
%.o: %.c
	$(CC) $(INC) -c $< -o $@ $(CFLAGS)

%.o:%.cpp
	$(XX) $(INC) -c $< -o $@ $(CFLAGS)

SOURCES = $(wildcard *.c *.cpp) \
	$(wildcard ./config/*.c  ./config/*.cpp ) \
	$(wildcard ./systemState/*.c  ./systemState/*.cpp ) \
	$(wildcard ./cloudAppCommu/*.c  ./cloudAppCommu/*.cpp )  \
	$(wildcard ./accessCard/*.c  ./accessCard/*.cpp )

OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))

$(TARGET) : $(OBJS)
	$(XX) $(OBJS) $(LIB) -o $(TARGET)  
	chmod a+x $(TARGET)
	mkdir -p /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/
	cp -r $(TARGET) /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/Terminal
	mkdir -p /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin
	cp -r /home/incast/wget/wget-1.17/install/bin/wget /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/wget
	##cp -r $(TARGET) $(NGINX_PATH)/Terminal
	##cp -r ./config/terminal.config $(NGINX_PATH)/terminal.config
	##cp -r ./config/edu_cloud_html.config $(NGINX_PATH)/edu_cloud_html.config
	cp -r $(TARGET) $(NGINX_PATH)/Terminal
	cp -r ./config/terminal.config $(NGINX_PATH)/terminal.config
	cp -r ./config/edu_cloud_html.config $(NGINX_PATH)/edu_cloud_html.config
	cp -r ./1.sh /usr/local/nginx/html/1.sh
	##cp -r ./accessCard/accessCard.config $(NGINX_PATH)/accessCard.config
#	adb push $(TARGET) /sdcard/edu/Terminal 
#	adb shell
#	./toclient.sh 
#	mount -t yaffs2 -o remount,rw,noatime,nodiratime /dev/mtdblock0 /sdcard
#UVC Camera (046d:081b)
#Webcam C170

clean:
	rm -rf *.o $(TARGET) 


#cp -r /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/screenrecord /usr/local/nginx/html/screenrecord
#cp -r /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/micrecord /usr/local/nginx/html/micrecord
#cp -r /home/incast/rk3288.4.4.2/out/target/product/rk3288/system/bin/aincastoplay /usr/local/nginx/html/aincastoplay
#./configure --enable-static --host=arm-linux  --prefix=/home/incast/out CC=arm-linux-androideabi-gcc CXX=arm-linux-androideabi-g++
#https://download.samba.org/pub/samba/stable/samba-4.3.6.tar.gz
